/**
 * 描述: 故障现象详情页
 *
 * @author chengguang
 * @since 2021/11/18 17:54
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'zmnSelect'], function (exports) {
        var $ = layui.$;
        var form = layui.form;
        var layer = layui.layer;
        var table = layui.table;
        var laypage = layui.laypage;
        var layedit = layui.layedit;
        let zmnSelect = layui.zmnSelect;

        form.render(null, "zmn-form");
        labelSelect.init('maintainIds', json.maintains.length > 0 ? json.maintains : null, "/base/phenomenon/listMaintain");

        // 提交
        form.on('submit(zmn-form-submit)', function (obj) {
            let maintainIds = obj.field.maintainIds;
            var phenId = json.phenId;
            var url = "/base/phenomenon/addPhenomenonMaintain.action?phenId=" + phenId + "&maintainIds=" + maintainIds;
            $.ajax({
                async: false,
                type: "POST", url: url,
                contentType: "application/json", dataType: "json", data: [],
                success: function (result) {
                    if (result.status == 200) {
                        //提示信息为弹出框形式
                        layer.msg(result.message, {time: 1000}, () => {
                            zmnLayUtil.closeThisIframe(parent, {reloadPage: true});
                            parent.window.document.forms[0].submit();
                        });
                    } else {
                        layer.msg(result.message, {"icon": 2});
                    }

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                }
            })
            return false;
        });

        //对外暴露的接口
        exports('plat_phenomenon_relation_maintain', {});
    }
)
;
